import pymongo
from datetime import datetime
import sys
from datetime import timedelta
import time
import json
client = pymongo.MongoClient('mongodb://cs_user:cmcc5188@localhost:12018/cs_recharge')
db = client.cs_recharge
coll = db.rechange
import redis
conn = redis.Redis()
while True:
    test_range = coll.find({"orderstate": "9", 'tel_type': "unicom"})
    for i in test_range:
        # print(i)
        if 60 * 60 * 12 > time.time() - i['time'] > 420:
            print("放入查询队列%s", i['ordernumber'])
            conn.lpush('unicom_recharge', json.dumps({"ordernumber": i['ordernumber']}))
            time.sleep(1)
    print(test_range.count())
    time.sleep(60*30)
